// XMLLib version 1
//
// Author
//
//   Thomas Koos (info@muetze1.de)
//   www.muetze1.de
//
// License
//
//   This Source Code Form is subject to the terms of the Mozilla Public
//   License, v. 1.1. If a copy of the MPL was not distributed with this
//   file, You can obtain one at http://mozilla.org/MPL/1.1/.
//
// Description
//
//   String adapter configuration class. This class will be instanced
//   and published by TXMLLibConfig.
//
// Revision
//
//  $Id: StrAdapterOptions.pas 18 2014-04-21 21:28:10Z muetze1@gmail.com $
//

unit StrAdapterOptions;

interface

{$Z+}  // equal to $Z4 on newer compilers

type
    // The TSAEntityCoding defines the entity coding behaviour on exporting the
    // XML data. All characters will be coded in named format by default.
    //
    // Parameters
    //   saecNamed         - The entity will be named if known to the library.
    //   saecDecimal       - The entity will be coded in decimal form.
    //   saecHexadecimal   - The entity will be coded in hexadecimal form.
    //   saecDisabled      - All left unchanged.
  TSAEntityCoding = ( saecNamed, saecDecimal, saecHexadecimal, saecDisabled );

    // Class containing all configuration items for the string adapters. Every string adapter instance
    // holds a reference to one instance of this class.
  TStringAdapterOptions = Class
  Public
      // This option defines the behaviour of the string decoders on illegal character.
      // If set to true, the illegal characters will be copied and ignored - false will
      // raise an ESAIllegalCharacterException exception.
      //
      // See Also
      //   ESAIllegalCharacterException
    IgnoreIllegalCharacter: Boolean;

      // Set this according to entity coding (named "&quot;", decimal "&#34;",
      // hexadecimal "&#x22;")
    EntityCoding: TSAEntityCoding;

      // Set this to true to prevent the escaping of the apostroph char.
    ExcludeApostroph: Boolean;

      // Defines the default character assigned on charset transcoding for invalid or not convertable
      // characters. Defaults to question mark (?).
    DefaultCharacter: Char;

    Constructor Create;

    Procedure SetDefaults; virtual;
  End;

implementation

{ TStringAdapterOptions }

constructor TStringAdapterOptions.Create;
begin
  inherited Create;

  SetDefaults;
end;

  // Resets all configuration items to their default values. The default values
  // are:
  //
  // <table>
  //  IgnoreIllegalCharacter: false
  //  EntityCoding: saecNamed
  //  ExcludeApostroph: false
  // </table>
procedure TStringAdapterOptions.SetDefaults;
begin
  IgnoreIllegalCharacter := false;
  EntityCoding := saecNamed;
  ExcludeApostroph := false;
  DefaultCharacter := '?';
end;

end.
